package com.banmao.desktoptools.util;

import org.springframework.core.annotation.AnnotationUtils;

import java.lang.annotation.Annotation;

/**
 *  注解工具类，获取传入的类上的指定注解的相关值
 */
public class AnnotationUtil {

    // 获取value字段
    public static <A extends Annotation> String getValue(Class aClass, Class<A> fxmlViewClass) {
        A annotation = AnnotationUtils.findAnnotation(aClass, fxmlViewClass);
        if(annotation != null) {
            Object value = AnnotationUtils.getValue(annotation, "value");
            if(value != null) {
                return (String) value;
            }
        }
        return null;
    }


}
